<!DOCTYPE html>
<html>
<head>
<title>管理员列表</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="../../css/bootstrap.min.css">
<link rel="stylesheet" href="../../css/font-awesome.min.css">
<link rel="stylesheet" href="../../plugins/jqgrid/ui.jqgrid-bootstrap.css">
<link rel="stylesheet" href="../../plugins/ztree/css/metroStyle/metroStyle.css">
<link rel="stylesheet" href="../../css/main.css">
<script src="../../libs/jquery.min.js"></script>
<script src="../../plugins/layer/layer.js"></script>
<script src="../../libs/bootstrap.min.js"></script>
<script src="../../libs/vue.min.js"></script>
<script src="../../libs/validator.min.js"></script>
<script src="../../plugins/jqgrid/grid.locale-cn.js"></script>
<script src="../../plugins/jqgrid/jquery.jqGrid.min.js"></script>
<script src="../../plugins/ztree/jquery.ztree.all.min.js"></script>
<script src="../../plugins/jquery-validation/jquery.validate.min.js"></script>
<script src="../../plugins/jquery-validation/jquery.validate.addMethod.js"></script>
<script src="../../js/common.js"></script>
<style>
	.regTxt{
		color:#e43939;
		dispaly:none;
	}
</style>
</head>
<body>
<div id="rrapp" v-cloak>
	<div v-show="showList">
		<div class="grid-btn">
			<div class="form-group col-sm-2">
				<input type="text" class="form-control" v-model="q.username" @keyup.enter="query" placeholder="用户名">
			</div>
			<a class="btn btn-default" @click="query">查询</a>
			<a v-if="hasPermission('sys:user:save')" class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
			<a v-if="hasPermission('sys:user:update')" class="btn btn-primary" @click="Modify()"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
			<a v-if="hasPermission('sys:user:delete')" class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
		</div>
	    <table id="jqGrid"></table>
	    <div id="jqGridPager"></div>
    </div>
    
    <div v-show="!showList" class="panel panel-default">
		<div class="panel-heading">{{title}}</div>
		<form class="form-horizontal" id="form">
			<div class="form-group">
			   	<div class="col-sm-2 control-label">用户名</div>
			   	<div class="col-sm-10">
			      <input type="text" id="userRegister"  class="form-control" name="userRegister" v-model="user.username" placeholder="登录账号"  onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\@\.]/g,'')"/>
			    </div>
			</div>
			<div class="form-group">
			   	<div class="col-sm-2 control-label">密码</div>
			   	<div class="col-sm-10">
			      <input type="password" class="form-control" v-model="user.password" name="password" id="password" placeholder="密码" />
			    </div>
			</div>
			<div class="form-group">
			   	<div class="col-sm-2 control-label">确认密码</div>
			   	<div class="col-sm-10">
			      <input type="password" class="form-control" v-model="user.confirmpassword" name="confirmpassword" id="confirmpassword" placeholder="确认密码"/>
			    </div>
			</div>
			<div class="form-group">
			   	<div class="col-sm-2 control-label">邮箱</div>
			   	<div class="col-sm-10">
			      <input type="text" class="form-control" v-model="user.email" id="email" placeholder="邮箱"/>
			    </div>
			</div>
			<div class="form-group">
			   	<div class="col-sm-2 control-label">手机号</div>
			   	<div class="col-sm-10">
			      <input type="text" class="form-control" v-model="user.mobile" id="mobile" name="mobile" placeholder="手机号"/>
			    </div>
			</div>
			<div class="form-group">
			   	<div class="col-sm-2 control-label">角色</div>
			   	<div class="col-sm-10">
				   	<label v-for="role in roleList" class="checkbox-inline">
					 <!--  <input type="checkbox" :value="role.roleId" v-model="user.roleIdList">{{role.roleName}} -->
					 <input type="radio" :value="role.roleId" name="roleId" v-model="user.roleid">{{role.roleName}}
					</label>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label">状态</div> 
				<label class="radio-inline">
				  <input type="radio" name="status" value="0"/> 禁用
				</label>
				<label class="radio-inline">
				  <input type="radio" name="status" value="1" checked="checked" /> 正常
				</label>
			</div>
			<div class="form-group">
				<div class="col-sm-2 control-label"></div> 
				<input type="button" class="btn btn-primary" @click="saveOrUpdate" value="确定"/>
				&nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回"/>
			</div>
		</form>
	</div>
		<div class="modal fade" id="newt" >  <!-- id="Yprice"  -->
		    <div class="modal-dialog" role="document" style="width: 600px;height: 800px;">
		        <div class="modal-content">
		            <div class="modal-header">
		                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
		                <h4 class="modal-title">{{title}}</h4>
		            </div>
		            <div class="modal-body">
		                <form class="form-horizontal" id="form">
							<div class="form-group">
							   	<div class="col-sm-2 control-label">用户名</div>
							   	<div class="col-sm-10">
							      <input type="text" id="userRegister" readonly="readonly" class="form-control" name="userRegister" v-model="user.username" placeholder="登录账号"  onkeyup="value=value.replace(/[^\a-\z\A-\Z0-9\u4E00-\u9FA5\@\.]/g,'')"/>
							    </div>
							</div>
							<div class="form-group">
							   	<div class="col-sm-2 control-label">密码</div>
							   	<div class="col-sm-10">
							      <input type="password" class="form-control" v-model="user.password" name="password" id="password" placeholder="密码" /><font color=red>不输入代表不修改密码</font>
							    </div>
							</div>
							<div class="form-group">
							   	<div class="col-sm-2 control-label">确认密码</div>
							   	<div class="col-sm-10">
							      <input type="password" class="form-control" v-model="user.confirmpassword" name="confirmpassword" id="confirmpassword" placeholder="确认密码"/>
							    </div>
							</div>
							<div class="form-group">
							   	<div class="col-sm-2 control-label">邮箱</div>
							   	<div class="col-sm-10">
							      <input type="text" class="form-control" v-model="user.email" id="email" placeholder="邮箱"/>
							    </div>
							</div>
							<div class="form-group">
							   	<div class="col-sm-2 control-label">手机号</div>
							   	<div class="col-sm-10">
							      <input type="text" class="form-control" v-model="user.mobile" id="mobile" name="mobile" placeholder="手机号"/>
							    </div>
							</div>
							<div class="form-group">
							   	<div class="col-sm-2 control-label">角色</div>
							   	<div class="col-sm-10">
								   	<label v-for="role in roleList" class="checkbox-inline">
									 <!--  <input type="checkbox" :value="role.roleId" v-model="user.roleIdList">{{role.roleName}} -->
									 <input type="radio" :value="role.roleId" name="roleId" v-model="user.roleid">{{role.roleName}}
									</label>
								</div>
							</div>
							<!-- <div class="form-group">
								<div class="col-sm-2 control-label">状态</div> 
								<label class="radio-inline">
								  <input type="radio" name="status" value="0" v-model="user.userStatus"/> 禁用
								</label>
								<label class="radio-inline">
								  <input type="radio" name="status" value="1" v-model="user.userStatus"/> 正常
								</label>
							</div> -->
						</form>
		            </div>
		            <div class="modal-footer">
		            <input type="button" class="btn btn-primary"  @click="saveOrUpdate" value="确定"/>
		                <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
		            </div>
		        </div>
		    </div>
		</div>
</div>


<script src="../../js/modules/sys/user.js"></script>
<script type="text/javascript">
function validform(){
	  /*关键在此增加了一个return，返回的是一个validate对象，这个对象有一个form方法，返回的是是否通过验证*/
	  return $("#form").validate({
	     rules : {
	    	 userRegister : {
	                required : true,
	                minlength: 2,
	                maxlength: 20
	            },
	            password: {
	                required: true,
	                minlength: 6
	            },
	            confirmpassword: {
	                required: true,
	                minlength: 6,
	                equalTo: "#password"

	            },
	            mobile: {
                  required: true,
                  mopbilephone: true
        		}
        	
	
	        },
	        messages : {
	        	userRegister : {
	                required : '用户名必填',
	                minlength: '最少输入2个字符',
	                maxlength: '最多输入20个字符',
	            },
	            password: {
	                required: "没有填写密码",
	                minlength: "密码不能小于{0}个字符"
	            },
	            confirmpassword: {
	                required: "没有确认密码",
	                minlength: "确认密码不能小于{0}个字符",
	                equalTo: "两次输入密码不一致"
	            },
	            email: {
                  required: '请输入电子邮件',
                  email: '请检查电子邮件的格式'
         		},
         		mobile: {
                  required: '请输入手机号码',
         		}

	        }
	  });
	}
	//注册表单验证
	$(validform());
</script>
</body>
</html>